﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using aboveXWords.GUI;

namespace aboveXWords
{
  public partial class PictureDialog : Form
  {
    private readonly Picture m_picture;

    public PictureDialog(Picture picture)
    {
      m_picture = picture;
      InitializeComponent();
      if (picture.Image != null)
        pictureBox.Image = picture.Image;
    }

    private void ButtonImageClick(object sender, EventArgs e)
    {
      if (openFileDialog.ShowDialog() != DialogResult.OK) return;
      pictureBox.Image = new Bitmap(openFileDialog.FileName);
    }

    private void PictureDialog_FormClosing(object sender, FormClosingEventArgs e)
    {
      if (DialogResult != DialogResult.OK) return;
      m_picture.Image = pictureBox.Image;
      m_picture.Value = textBoxSentense.Text;
    }
  }
}
